package com.guoliang.eduService.controller;

import com.guoliang.commonUtils.CommonResult;
import com.guoliang.eduService.entity.subject.OneSubject;
import com.guoliang.eduService.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author leo
 * @since 2023-01-17
 */
@Api(description = "课程分类管理")
@RestController
@RequestMapping("/eduService/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;
    @ApiOperation("课程excel批量导入")
    @PostMapping("addSubject")
    public CommonResult addSubject(MultipartFile file){
        eduSubjectService.importSubjectData(file,eduSubjectService);
        return CommonResult.ok().message("添加成功");
    }
    //课程分类树形列表
    @ApiOperation("获取课程分类树形结构")
    @GetMapping("getAllSubject")
    public CommonResult getAllSubject(){
        List<OneSubject> list=eduSubjectService.getAllOneTwoSubjects();
        return CommonResult.ok().data("list",list);
    }
}
